all:run
c_src=$(shell find ./src -name "*.c")
c_obj=$(patsubst ./src/%.c,./obj/%.o,$(c_src))
inc_path=./inc
inc=$(foreach item,$(inc_path),-I$(item))
lib_path=./lib
lib=$(foreach item,$(lib_path),-L$(item))

lib_a=$(subst lib,,$(notdir $(basename $(filter %.a, $(shell find $(lib_path) -name "lib*")))))
lib_a_l=$(foreach item,$(lib_a),-l$(item))

lib_so=$(subst lib,,$(notdir $(basename $(filter %.so,$(shell find $(lib_path) -name "lib*")))))
lib_so_l=$(foreach item,$(lib_so),-l$(item))

option=-Wall -O3 $(inc) $(lib) $(lib_so_l) $(lib_a_l)

./obj/%.o:./src/%.c
	mkdir -p $(dir $@)
	cc -c $^ -o $@ $(option)
workspace/exe:$(c_obj)
	@mkdir -p $(dir $@)
	cc $^ -o $@ $(option) 
run:workspace/exe
	./workspace/exe
debug:
	@echo $(c_src)
	@echo $(lib_a_l)
	@echo $(lib_so_l)
	
.PHONY:debug
